<%@page contentType="text/html" pageEncoding="UTF-8"%>

<jsp:useBean id="admBean" class="struts.actions.AdminAction" scope="application"/>
<jsp:setProperty name="admBean" property="*"/>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>SMRI - Adminitracion</title>
    </head>
    <body>
        <h1>Zona de Administraci&oacute;n</h1>        

        <%
           if(request.getParameter("fileName") == null)
           {
           %>
           <h3>Subir Fichero</h3>
            <form method="POST" enctype="multipart/form-data" action="<%= request.getContextPath()%>/UploadFile">
                Fichero: <input type="file" name="fileName"/>
                <input type="submit" value="Indexar">
            </form>
        <%
                if(request.getParameter("exists") != null) {
                     %><font color="red">Fichero ya indexado</font><%
                }                
           %>
        <%
           }  
            else
            {
                admBean.addFile(request.getParameter("fileName"), request.getParameter("path"));
                admBean.saveIndex();
                response.sendRedirect("admin.jsp");
            }
           %>

         <%
            if(request.getParameter("nofiles") != null) {
                %><font color="red">No se puede cargar el indice. Falta algun fichero</font><%
            }
            else if(request.getParameter("loadfiles") != null) {
                admBean.loadIndex();
                //response.sendRedirect("admin.jsp");
            }
            %>
        <form method="POST" action="<%= request.getContextPath()%>/LoadIndex">
            <input type="submit" value="Cargar Indice">
        </form>

        <%
           if(request.getParameter("generatedRel") != null)
               admBean.generatedRel();
           %>

        <form method="POST" action="<%= request.getContextPath()%>/GenerateREL">
            <input type="submit" value="Generar fichero .rel">
        </form>
         

         <h3>Ver indice</h3>
         Index: <%= admBean.indexToString() %>

    </body>
</html>
